package com.aqie.easy.string;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 929. 独特的电子邮件地址
 */

public class NumUniqueEmails {
    public int numUniqueEmails(String[] emails) {
        return (int) Arrays.stream(emails).map(a1 -> {
            a1 = a1.replaceAll("\\+.*@","@");
            while(a1.matches(".*\\..*@.*")){
                a1 = a1.replaceFirst("\\.", "");
            }
            return a1;
        }).distinct().count();
    }

    public static void main(String[] args) {
        String email = "test.email+alex@leetcode.com";
        String regex = ".*.*@*.com";
        Matcher matcher = Pattern.compile(regex).matcher(email);
        System.out.println(matcher.matches());
    }
}
